#!/bin/env python
# -*- coding: utf-8 -*-

#  This file is part of GLExDrv_DSO8060.
#
#  GLExDrv_DSO8060 is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  GLExDrv_DSO8060 is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Lesser General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with GLExDrv_DSO8060.  If not, see <http://www.gnu.org/licenses/>.


# Demo script for DSO8060 driver.
# Activates the siggen, generates a waveform, and loads it into the
# siggen's sample memory.
# (C) 2012 Greg Courville <greg_courville@greglabs.com>


from math import sin, sqrt, pi
from time import sleep
from random import Random
from dso8060 import DSO8060USB

rand = Random()
square = lambda x: (x > pi) and 1. or 0.
noisy_sine = lambda x : rand.random() + sin(x)
noisy_square = lambda x : 2. * rand.random() + square(x)

foo = DSO8060USB()
foo.setmode_dds()
foo.dds_set_clkdiv(100)
foo.dds_set_sync_out(True)
#foo.dds_fill_from_fn(sin, scale=0.5, offset=0.)
#foo.dds_fill_from_fn(noisy_square, scale=0.5, offset=0.)
foo.dds_fill_from_fn(noisy_sine, scale=0.5, offset=0.)
